package com.axonactive.yolo.webservice;

import java.io.IOException;

import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;

import com.axonactive.yolo.webservice.utils.Utils;

@Path("/profile")
public class Profile {

	/**
	 * @param jsonProfileParam
	 *            KEY:getProfileParam VALUE: {"userId":123}
	 * @return jsonObj
	 * @throws IOException
	 * @throws InterruptedException
	 */
	@POST
	@Path("/get")
	@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
	@Produces(MediaType.APPLICATION_JSON)
	public String getProfile(MultivaluedMap<String, String> profileParam)
			throws IOException, InterruptedException {
		// return Utils.call("get_profile/"
		// + Utils.encode(profileParam.getFirst("getProfileParam")));
		return Utils.call("get_profile/"
				+ profileParam.getFirst("getProfileParam"));
	}

	/**
	 * @param jsonProfileParam
	 *            KEY: updateProfileParam VALUE: { "userId":123,
	 *            "firstName":"Jack", "lastName":"Pham", "phone":"0905020891",
	 *            "gender":"1", "dateOfBirth":"1991/08/02",
	 *            "primaryEmail":"phuong.phamquang@axonactive.vn",
	 *            "newPassword":"encrypted_password",
	 *            "confirmPassword":"encrypted_password",
	 *            "defaultPassword":"encrypted_password",
	 *            "temporaryPassword":"encrypted_password", "currency":"SGD",
	 *            "alreadyAddedEmailSecondary"
	 *            :"[temp1@gmail.com, temp2@gmail.com, temp3@gmail.com]" }
	 * @return jsonObj
	 * @throws IOException
	 * @throws InterruptedException
	 */
	@POST
	@Path("/update")
	@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
	@Produces(MediaType.APPLICATION_JSON)
	public String updateProfile(MultivaluedMap<String, String> profileParam)
			throws IOException, InterruptedException {
		return Utils.call("update_profile/"
				+ profileParam.getFirst("updateProfileParam"));
	}

}